﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using Oracle.DataAccess.Client;

namespace PlanningGIS.Product
{
    /// <summary>
    /// 选择要显示的产品数据
    /// </summary>
    public partial class FrmChooseDate : Office2007Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmChooseDate()
        {
            InitializeComponent();
            dgrdvwTF.AutoGenerateColumns = false;
            
        }
        /// <summary>
        /// 加载窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmChooseDate_Load(object sender, EventArgs e)
        {
           
        }

        /// <summary>
        /// 获取选择的产品编号
        /// </summary>
        public string ID { get; private set; }

        /// <summary>
        /// 设置数据源
        /// </summary>
        /// <param name="datatable"></param>
        /// <param name="rname"></param>
        public void SetDataSource(DataTable datatable,string rname)
        {
            dgrdvwTF.AutoGenerateColumns = false;
            dgrdvwcolID.DataPropertyName = PlanningGIS.MetaData.MetaHelper.ID;
            dgrdvwcolTH.DataPropertyName = rname;
            dgrdvwcolSCRQ.DataPropertyName = "scrq";
            dgrdvwTF.DataSource = datatable;
        }

        /// <summary>
        /// 双击选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgrdvwTF_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == -1 || e.RowIndex == -1)
                return;
            ID = dgrdvwTF.Rows[e.RowIndex].Cells[dgrdvwcolID.Index].Value.ToString();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }                
    }
   
}
